<?php
/*
 * Created by PhpStorm.
 * Date: 16/9/27
 * Time: 下午3:20
 * User: liubin
 */

namespace api\Model;

use Think\Model;

class HospitalModel extends Model
{
    function __construct() {
        $this->model = M('HosptEntity');
    }

    public function getAgencyList($condition=array(),$field = array('*'), $page = 1, $pergage = 10, $order = 'sort asc') {
        $data = $this->model->where($condition)->field($field)->page($page, $pergage)->order($order)->select();
        foreach ($data as $key=>$val){
            $data[$key]['allnum'] = $this->model->where($condition)->count();
        }
        $data = $data ? $data : array();
        return $data;
    }

    public function getByDid($did, $field = array('*')) {
        $data = $this->model->where(array('hospt_id' => $did))->field($field)->find();
        return $data;
    }

    public function gethospt_name($did) {
        $data = $this->model->where('hospt_id='.$did)->getField('hospt_title');
        return $data;
    }


    public function setAgency($condition = array(),$param = array()) {
        $data = $this->model->where($condition)->setField($param);
        $data = $data ? $data : array();
        return $data;
    }
    

}